package it.canraid.leaflet.control;

import it.canraid.leaflet.control.activity.DrawActivity;
import it.canraid.leaflet.model.ReadMessagePill;
import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Toast;

public class ClickThumbnailListener implements OnClickListener {
    private ReadMessagePill rmp = null;
    private Activity context = null;

    public ClickThumbnailListener(Activity context, ReadMessagePill rmp) {
	super();
	this.rmp = rmp;
	this.context = context;
    }

    public void onClick(View v) {
	try {
	    Intent intent = new Intent(context, DrawActivity.class);
	    intent.putExtra(ReadMessagePill.class.getName(), rmp.generateAscii());
	    context.startActivity(intent);
	} catch (Exception e) {
	    e.printStackTrace();
	    Toast.makeText(context, "Errore interno: Impossibile serializzare il messaggio.", Toast.LENGTH_LONG).show();
	}
    }
}
